package grex.genes;
/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */
import grex.Prediction;
import grex.PredictionContainer;

public class Less extends Gene implements IContinuousOperator{
  private static final int NROFCILDREN=2;
  public Less(){
    super(NROFCILDREN);
  }

 public synchronized void execute(Gene parent,PredictionContainer data,int mode) throws GeneException {
      this.parent = parent;
        Gene[] childs = this.getChildren();
        /*PredictionContainer lResult = data;
        PredictionContainer rResult = data.clone();
        childs[0].execute(this, lResult, mode);
        childs[1].execute(this, rResult, mode);
        for (double[] key : data.keySet()) {
            if (lResult.get(key).getPrediction() <= rResult.get(key).getPrediction()) {
                data.get(key).setPrediction(1);
            } else {
                data.get(key).setPrediction(0);
            }
        }//*/
        //198463

        for(Prediction prediction:data.values()){
          if(((IOperatorTerminal)childs[0]).execute(this, prediction) <= ((IOperatorTerminal)childs[1]).execute(this, prediction))
              prediction.setCondition(true);
             else 
              prediction.setCondition(false);
        }//*/
  }

  public Object clone() {
    Less newLess= new Less();
    newLess.setOptions(ops);
    cloneChildren(newLess);
   // newLess.setParent(parent);
    return newLess;
 }
  public boolean equals(Object o){
        if(o instanceof Less){
            Less g =(Less) o;
            if(getChildren()[0].equals(g.getChildren()[0]) || getChildren()[0].equals(g.getChildren()[1]))
                if(getChildren()[1].equals(g.getChildren()[0]) || getChildren()[1].equals(g.getChildren()[1]))
                    return true;
        }
        return false;
    }

  public String toString(){
    return "<=";
  }

}
